package com.hxd.otc.module.my.adapter;

import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hxd.otc.R;
import com.hxd.otc.common.UserHelper;
import com.hxd.otc.module.my.bean.NoSenseBean;
import com.hxd.otc.utils.StringUtil;
import com.hxd.otc.utils.UIUtils;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/6/5 18:03
 * 描  述 :  ${全部订单页面}
 */
public class NoSenseAdapter extends BaseQuickAdapter<NoSenseBean.NoSenseData, BaseViewHolder> {


    public NoSenseAdapter() {
        super(R.layout.adapter_nosense_bill, null);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final NoSenseBean.NoSenseData item) {
        helper.setText(R.id.cb_time, item.createTime);

            helper.setText(R.id.tv_orderBuyCount, UIUtils.getContext().getString(R.string.buy_number, StringUtil.handleZero(item.orderBuyCount)));
        helper.setText(R.id.tv_orderSellCount, UIUtils.getContext().getString(R.string.sell_number, StringUtil.handleZero(item.orderSellCount)));

        helper.setText(R.id.tv_tradeBuyVolume, UIUtils.getContext().getString(R.string.buy_two_pla, StringUtil.handleZero(item.tradeBuyVolume), item.symbol));
        helper.setText(R.id.tv_tradeSellVolume, UIUtils.getContext().getString(R.string.sell_two_pla, StringUtil.handleZero(item.tradeSellVolume), item.symbol));

        helper.setText(R.id.tv_tradeBuyMoney, UIUtils.getContext().getString(R.string.buy_two_pla, StringUtil.handleZero(item.tradeBuyMoney), item.supportCurrencyCode));
        helper.setText(R.id.tv_tradeSellMoney, UIUtils.getContext().getString(R.string.sell_two_pla, StringUtil.handleZero(item.tradeSellMoney), item.supportCurrencyCode));

        if (UserHelper.isNonInductivePaySilver()) {
            helper.setText(R.id.tv_rebateVolume_hint, UIUtils.getContext().getString(R.string.profit_rebate));
            helper.setText(R.id.tv_rebateVolume, UIUtils.getContext().getString(R.string.nosense_two_placeholder,
                    StringUtil.handleZero(item.rebateVolume), item.symbol));
        } else {
            helper.setText(R.id.tv_rebateVolume_hint, UIUtils.getContext().getString(R.string.wallet_coin_free));
            helper.setText(R.id.tv_rebateVolume, UIUtils.getContext().getString(R.string.nosense_two_placeholder,
                    StringUtil.handleZero(item.feeVolume), item.symbol));
        }
        helper.setOnCheckedChangeListener(R.id.cb_time, new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    helper.setGone(R.id.rl_container, true);
                    helper.setGone(R.id.line4, false);
                } else {
                    helper.setGone(R.id.rl_container, false);
                    helper.setGone(R.id.line4, true);
                }
            }
        });
    }
}
